package com.srxz.mobilepharmacy.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 视图 vw_门诊费用
 */
@Entity
@Table(name = "vw_门诊费用")
@AllArgsConstructor
@NoArgsConstructor
@Data
@JsonInclude(value = JsonInclude.Include.NON_NULL)
public class ClinicRecView implements Serializable {
    @Id   // 添加一个空的id标识，因为jpa在映射实体是需要一个id，这个必须
    @Column(name = "id")
    private Integer id;

    @Column(name = "aid")
    private BigInteger aid;
    @Column(name = "patid")
    private BigInteger patid;
    @Column(name = "sn")
    private BigInteger sn;
    @Column(name = "ord")
    private Integer ord;
    @Column(name = "grp")
    private Integer grp;
    @Column(name = "mid")
    private Integer mid;
    @Column(name = "bn", length = 50)
    private String bn;
    @Column(name = "vdate")
    private Integer vdate;
    @Column(name = "attr")
    private Integer attr;
    @Column(name = "dep")
    private Integer dep;
    @Column(name = "dr")
    private Integer dr;
    @Column(name = "quan")
    private Double quan;
    @Column(name = "pr0")
    private Double pr0;
    @Column(name = "prr")
    @JsonSerialize(using = com.srxz.mobilepharmacy.util.CustomDoubleIntSerialize.class)
    private Double prr;
    @Column(name = "pri")
    private Double pri;
    @Column(name = "mny")
    private Double mny;
    @Column(name = "cs")
    private Integer cs;
    @Column(name = "mrn")
    private Integer mrn;
    @Column(name = "smed", length = 20)
    private String smed;
    @Column(name = "sdate")
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    private Date sdate;
    @Column(name = "acc")
    private Integer acc;
    @Column(name = "send")
    private Integer send;
    @Column(name = "up")
    private Integer up;
    @Column(name = "prescsn")
    private BigInteger prescsn;
    @Column(name = "prescid")
    private Integer prescid;
    @Column(name = "prescord")
    private Integer prescord;

    @Column(name = "gn")
    private String gn;
    @Column(name = "wn")
    private String wn;
    @Column(name = "made")
    private String made;
    @Column(name = "spr")
    private String spr;
    @Column(name = "utr")
    private String utr;
    @Column(name = "usag", length = 100)
    private String usag;
    @Column(name = "dt")
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    private Date dt;
    @Column(name = "pn")
    private BigInteger pn;
    @Column(name = "op")
    private String op;
    @Column(name = "prnt")
    private String prnt;
    @Column(name = "totalmny")
    private Double totalmny;
    @Column(name = "payer")
    private String payer;
    @Column(name = "bday")
    private Integer bday;
    @Column(name = "patType")
    private Integer patType;
    @Column(name = "years")
    private Integer years;
    @Column(name = "sex")
    private String sex;
    @Column(name = "nat")
    private String nat;
    @Column(name = "peo")
    private String peo;
    @Column(name = "voc")
    private String voc;
    @Column(name = "mar")
    private Integer mar;
    @Column(name = "addr")
    private String addr;
    @Column(name = "tel")
    private String tel;
    @Column(name = "corp")
    private String corp;
    @Column(name = "phone")
    private String phone;
    @Column(name = "cn")
    private String cn;
    @Column(name = "cnph")
    private String cnph;
    @Column(name = "prcid")
    private String prcid;
    @Column(name = "ssid")
    private String ssid;
    @Column(name = "ehid")
    private String ehid;
    @Column(name = "memid")
    private String memid;
    @Column(name = "card")
    private String card;
    @Column(name = "typ")
    private String typ;
    @Column(name = "typid")
    private Integer typid;
    @Column(name = "adept")
    private Integer adept;
    @Column(name = "auid")
    private BigInteger auid;
    @Column(name = "scode")
    private String scode;
    @Column(name = "rcode")
    private String rcode;
    @Column(name = "rcode_cl")
    private String rcode_cl;
    @Column(name = "hcode")
    private String hcode;
    @Column(name = "mtDeptID")
    private String mtDeptID;
    @Column(name = "AccTypeCode")
    private Integer AccTypeCode;
    @Column(name = "AccTypeName")
    private String AccTypeName;
    @Column(name = "AccTypeNote")
    private String AccTypeNote;
    @Column(name = "spec")
    private Integer spec;
    @Column(name = "anti")
    private Integer anti;
    @Column(name = "psyc")
    private Integer psyc;
    @Column(name = "qdjs")
    private String qdjs;
    @Column(name = "qdxz")
    private String qdxz;
    @Column(name = "goback")
    private BigInteger goback;
    @Column(name = "snauid")
    private BigInteger snauid;
    @Column(name = "micuscode")
    private String micuscode;
    @Column(name = "medName")
    private String medName;

    public ClinicRecView(Object[] objs) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        this.aid = objs[0]==null?null:new BigInteger(objs[0].toString());
        this.patid = objs[1]==null?null:new BigInteger(objs[1].toString());
        this.sn = objs[2]==null?null:new BigInteger(objs[2].toString());
        this.ord = objs[3]==null?null:new Integer(objs[3].toString());
        this.grp = objs[4]==null?null:new Integer(objs[4].toString());
        this.mid = objs[5]==null?null:new Integer(objs[5].toString());
        this.bn = objs[6]==null?null:objs[6].toString();
        this.vdate = objs[7]==null?null:new Integer(objs[7].toString());
        this.attr = objs[8]==null?null:new Integer(objs[8].toString());
        this.dep = objs[9]==null?null:new Integer(objs[9].toString());
        this.dr = objs[10]==null?null:new Integer(objs[10].toString());
        this.quan = objs[11]==null?null:new Double(objs[11].toString());
        this.pr0 = objs[12]==null?null:new Double(objs[12].toString());
        this.prr = objs[13]==null?null:new Double(objs[13].toString());
        this.pri = objs[14]==null?null:new Double(objs[14].toString());
        this.mny = objs[15]==null?null:new Double(objs[15].toString());
        this.cs = objs[16]==null?null:new Integer(objs[16].toString());
        this.mrn = objs[17]==null?null:new Integer(objs[17].toString());
        this.smed = objs[18]==null?null:objs[18].toString();
        this.sdate = null;
        String sdate = objs[19]==null?null:objs[19].toString().substring(0, objs[19].toString().lastIndexOf("."));
        if(sdate != null)
            this.sdate = sdf.parse(sdate);

        this.acc = objs[20]==null?null:new Integer(objs[20].toString());
        this.send = objs[21]==null?null:new Integer(objs[21].toString());
        this.up = objs[22]==null?null:new Integer(objs[22].toString());
        this.prescsn = objs[23]==null?null:new BigInteger(objs[23].toString());
        this.prescid = objs[24]==null?null:new Integer(objs[24].toString());
        this.prescord = objs[25]==null?null:new Integer(objs[25].toString());
        this.gn = objs[26]==null?null:objs[26].toString();
        this.wn = objs[27]==null?null:objs[27].toString();
        this.made = objs[28]==null?null:objs[28].toString();
        this.spr = objs[29]==null?null:objs[29].toString();
        this.utr = objs[30]==null?null:objs[30].toString();
        this.usag = objs[31]==null?null:objs[31].toString();

        this.dt = null;
        String dt = objs[32]==null?null:objs[32].toString().substring(0, objs[32].toString().lastIndexOf("."));
        if(dt != null)
            this.dt = sdf.parse(dt);

        this.pn = objs[33]==null?null:new BigInteger(objs[33].toString());
        this.op = objs[34]==null?null:objs[34].toString();
        this.prnt = objs[35]==null?null:objs[35].toString();
        this.totalmny = objs[36]==null?null:new Double(objs[36].toString());
        this.payer = objs[37]==null?null:objs[37].toString();
        this.bday = objs[38]==null?null:new Integer(objs[38].toString());
        this.patType = objs[39]==null?null:new Integer(objs[39].toString());
        this.years = objs[40]==null?null:new Integer(objs[40].toString());
        this.sex = objs[41]==null?null:objs[41].toString();
        this.nat = objs[42]==null?null:objs[42].toString();
        this.peo = objs[43]==null?null:objs[43].toString();
        this.voc = objs[44]==null?null:objs[44].toString();
        this.mar = objs[45]==null?null:new Integer(objs[45].toString());
        this.addr = objs[46]==null?null:objs[46].toString();
        this.tel = objs[47]==null?null:objs[47].toString();
        this.corp = objs[48]==null?null:objs[48].toString();
        this.phone = objs[49]==null?null:objs[49].toString();
        this.cn = objs[50]==null?null:objs[50].toString();
        this.cnph = objs[51]==null?null:objs[51].toString();
        this.prcid = objs[52]==null?null:objs[52].toString();
        this.ssid = objs[53]==null?null:objs[53].toString();
        this.ehid = objs[54]==null?null:objs[54].toString();
        this.memid = objs[55]==null?null:objs[55].toString();
        this.card = objs[56]==null?null:objs[56].toString();
        this.typ = objs[57]==null?null:objs[57].toString();
        this.typid = objs[58]==null?null:new Integer(objs[58].toString());
        this.adept = objs[59]==null?null:new Integer(objs[59].toString());
        this.auid = objs[60]==null?null:new BigInteger(objs[60].toString());
        this.scode = objs[61]==null?null:objs[61].toString();
        this.rcode = objs[62]==null?null:objs[62].toString();
        this.rcode_cl = objs[63]==null?null:objs[63].toString();
        this.hcode = objs[64]==null?null:objs[64].toString();
        this.mtDeptID = objs[65]==null?null:objs[65].toString();
        this.AccTypeCode = objs[66]==null?null:new Integer(objs[66].toString());
        this.AccTypeName = objs[67]==null?null:objs[67].toString();
        this.AccTypeNote = objs[68]==null?null:objs[68].toString();
        this.spec = objs[69]==null?null:new Integer(objs[69].toString());
        this.anti = objs[70]==null?null:new Integer(objs[70].toString());
        this.psyc = objs[71]==null?null:new Integer(objs[71].toString());
        this.qdjs = objs[72]==null?null:objs[72].toString();
        this.qdxz = objs[73]==null?null:objs[73].toString();
        this.goback = objs[74]==null?null:new BigInteger(objs[74].toString());
        this.snauid = objs[75]==null?null:new BigInteger(objs[75].toString());
        this.micuscode = objs[76]==null?null:objs[76].toString();
        this.medName = objs[77]==null?null:objs[77].toString();
    }

}
